<!DOCTYPE html>
<html lang="zh-CN"  xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="common/layout">
<head>
    <title>公司信息修改</title>
    <script th:inline="javascript">
        $(function(){
            setTimeout(function(){
                $("#company_form").ajaxForm({
                            callback: function(data) {
                                if (data.valid) {
                                    self.location.href = data.url || '/';
                                } else {
                                    alert(data.errorMsg);
                                }
                            },
                            validate: function(data) {
                                var company_name = $("#company_name").val();
                                if(company_name.length==0){
                                    alert("名称不能为空");
                                    return false;
                                }
                                if(company_name.length>10){
                                    alert("名称最大长度为10");
                                    return false;
                                }
                                var app_id = $("#appid").val();
                                if(app_id.length==0){
                                    alert("app id不能为空");
                                    return false;
                                }
                                var app_secret = $("#appsecret").val();
                                if(app_secret.length==0){
                                    alert("app secret不能为空");
                                    return false;
                                }

                                return true;
                            }
                        }
                )
            },200);
        });

        function edit_cancel() {
            self.location.href = '/admin/company';
        };
    </script>
</head>
<body>
<section layout:fragment="top_menu" style="text-align: left;padding-left: 20px">
    <!--<span style="font-size: 20px">修改店铺</span>-->
</section>

<section layout:fragment="content">
    <div class="main" style="margin: 5px">
        <form id="company_form" class="form" th:action="@{/admin/company/{id}(id=${company.id})}" th:object="${company}" th:method="PUT">
            <table>
                <tbody>
                <tr>
                    <td style="text-align: right;">
                        <label for="company_name">公司名</label>
                    </td>
                    <td>
                        <input id="company_name" th:field="*{name}"  type="text" >
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;">
                        <label for="appid">appid</label>
                    </td>
                    <td>
                        <input id="appid" th:field="*{appid}"   type="text" >
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;">
                        <label for="appsecret">appsecret</label>
                    </td>
                    <td>
                        <input id="appsecret" th:field="*{appsecret}"   type="text" >
                    </td>
                </tr>

                <tr>
                    <td colspan="2" style="text-align: center">
                        <input type="submit" class=" new_button_yellow input_submit" value="保存">
                        <input type="button" onclick="javascript:edit_cancel()"  class=" new_button_yellow " value="取消">
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</section>

</body>

</html>
